<template>
  <header class="shop-introduction">
    <div class="bgc">
      <img :src="shopIntroduction.img" alt="" />
    </div>
    <section class="main">
      <img :src="shopIntroduction.img" alt="" />
      <div class="text">
        <div class="name">
          {{ shopIntroduction.name }}
        </div>
        <div class="tips">
          商家配送 / 分钟送达 / 配送费¥{{ shopIntroduction.tips }}
        </div>
        <div claclass="notice">公告：{{ shopIntroduction.notice }}</div>
      </div>
      <div class="arrow" @click="handleSkipShopDetail"></div>
    </section>
    <section
      class="activity"
      v-if="
        Object.values(
          shopIntroduction.activities ? shopIntroduction.activities : {}
        ).length !== 0
      "
    >
      <div class="left">
        <span
          class="icon"
          :style="{
            backgroundColor: `#${shopIntroduction.activities[0].icon_color}`,
          }"
          >{{ shopIntroduction.activities[0].icon_name }}</span
        >
        <span class="desc"
          >{{ shopIntroduction.activities[0].description }}(APP专享)</span
        >
      </div>
      <div class="right" @click="handleActivitiesDetail">
        <span>{{ shopIntroduction.activities.length }}个活动</span>
        <span class="arrow"></span>
      </div>
    </section>
    <section class="activities-detail" v-show="isClose">
      <div class="name">
        {{ shopIntroduction.name }}
      </div>
      <div
        class="preferential-information"
        v-if="
          Object.values(
            shopIntroduction.activities ? shopIntroduction.activities : {}
          ).length !== 0
        "
      >
        <span class="title">优惠信息</span>
        <div
          v-for="(item, index) in shopIntroduction.activities"
          :key="index"
          class="activitie"
        >
          <span
            :style="{ backgroundColor: `#${item.icon_color}` }"
            class="icon"
            >{{ item.icon_name }}</span
          >
          <span class="desc">{{ item.description }}</span>
        </div>
      </div>
      <div class="business-announcement">
        <div class="title">商家公告</div>
        <div class="notice">
          {{ shopIntroduction.notice }}
        </div>
      </div>
      <div class="close" @click="handleCloseActivitiesDetail">
        <svg class="svg">
          <use xlink:href="#close"></use>
        </svg>
      </div>
    </section>
  </header>
</template>

<script>
export default {
  data() {
    return {
      isClose: false,
    };
  },
  props: {
    shopIntroduction: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  watch: {
    shopIntroduction(value) {
      this.$bus.$emit("activities", value.activities);
    },
  },
  methods: {
    handleSkipShopDetail() {
      this.$router.push("/shop/shopDetail");
    },
    handleActivitiesDetail() {
      this.isClose = true;
    },
    handleCloseActivitiesDetail() {
      this.isClose = false;
    },
  },
};
</script>
<style lang="less" scoped>
.shop-introduction {
  position: relative;
  top: 0;
  padding: 10px;
  background-color: rgba(176, 179, 195, 0.8);
  font-size: 12px;
  color: #fff;
  .bgc {
    position: absolute;
    top: -25px;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
    z-index: -1;
    img {
      width: 100%;
      filter: blur(5px);
    }
  }
  .main {
    display: flex;
    align-items: center;
    img {
      width: 65px;
      height: 65px;
    }
    .text {
      flex: 1;
      margin: 0 10px;
      .name {
        font-weight: bold;
        font-size: 18px;
      }
      .tips {
        margin: 10px 0;
      }
    }
    .arrow {
      width: 10px;
      height: 10px;
      border-top: 2px solid #fff;
      border-left: 2px solid #fff;
      transform: rotate(135deg);
    }
  }
  .activity {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    .left {
      .icon {
        padding: 2px;
        margin-right: 5px;
        font-size: 10px;
      }
    }
    .right {
      .arrow {
        display: inline-block;
        width: 8px;
        height: 8px;
        border-top: 1px solid #fff;
        border-left: 1px solid #fff;
        margin-left: 5px;
        transform: rotate(135deg);
      }
    }
  }
  .activities-detail {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 40px 20px;
    background-color: #262626;
    z-index: 9;
    .name {
      text-align: center;
      font-size: 18px;
    }
    .preferential-information {
      .activitie {
        margin-bottom: 5px;
        .icon {
          margin-right: 10px;
          padding: 2px;
          font-size: 10px;
        }
      }
    }
    .preferential-information,
    .business-announcement {
      margin-top: 50px;
      text-align: center;
      .title {
        display: inline-block;
        padding: 5px 10px;
        border: 1px solid #3b3b3b;
        margin-bottom: 20px;
        border-radius: 10px;
      }
      .activitie,
      .notice {
        text-align: left;
      }
    }
    .close {
      position: absolute;
      right: 50%;
      bottom: 40px;
      text-align: center;
      transform: translateX(50%);
      .svg {
        width: 50px;
        height: 50px;
      }
    }
  }
}
</style>